function addNews()
{
  
				var titleita = $('#titleNewsIta').val();
				var titleeng = $('#titleNewsEng').val();
				var link = encodeURI($('#linkNews').val());
				var fckcontentita = escape(FCKeditorAPI.GetInstance('editNewsIta').GetXHTML());
				var fckcontenteng = escape(FCKeditorAPI.GetInstance('editNewsEng').GetXHTML());
				var ajaxattempt = $('#hiddenNews').val();
			  
			  var bool=$('#formaddnews').validate().form();
				if(!bool){

				}
        else
        {		
					  
			    $('#formnews').append('<img src="img/loading.gif" alt="Currently Loading" id="loading" />');
				  
          $.ajax({
				
					url: 'include/backOfficeHandler.inc.php',
					type: 'POST',
					data: 'titleita=' + titleita + '&titleeng=' + titleeng + '&link=' + link + '&fckcontentita=' + fckcontentita + '&fckcontenteng=' + fckcontenteng + '&ajaxattempt=' + ajaxattempt,
				
					success: function(result) {
					  $('#loading').fadeOut(500, function() {
							$(this).remove();
						});
						$('div#formaddnews').replaceWith('<div id="response">' + result + '</div>');

				}
				});
			}
				return false;	
}

function delNews(idn)
{
        var id = idn.substring(1);
				var ajaxattempt = $('#hiddendelNews').val();
				
	
        if(confirm("Are you sure?"))
        {			
        	
    				$.ajax({
    				
    					url: 'include/backOfficeHandler.inc.php',
    					type: 'POST',
    					data: 'id=' + id + '&ajaxattempt=' + ajaxattempt,
    					
    					success: function(result) {
						   $("#i"+id).parents('table').effect("explode");
					     }
    					
    				});
        }	
        	
        	
        	
					
				return false;
}


function editNews()
{
			  $('#formnews').append('<img src="img/loading.gif" alt="Currently Loading" id="loading" />');
			  
				var titleita = $('#titleNewsIta').val();
				var titleeng = $('#titleNewsEng').val();
				var link = encodeURI($('#linkNews').val());
				var fckcontentita = escape(FCKeditorAPI.GetInstance('editNewsIta').GetXHTML());
				var fckcontenteng = escape(FCKeditorAPI.GetInstance('editNewsEng').GetXHTML());
				var ajaxattempt = $('#hiddenNews').val();
			  
				$.ajax({
				
					url: 'include/backOfficeHandler.inc.php',
					type: 'POST',
					data: 'titleita=' + titleita + '&titleeng=' + titleeng + '&link=' + link + '&fckcontentita=' + fckcontentita + '&fckcontenteng=' + fckcontenteng + '&ajaxattempt=' + ajaxattempt,
				
					success: function(result) {
					  $('#loading').fadeOut(500, function() {
							$(this).remove();
						});
						$('div#formaddnews').replaceWith('<div id="response">' + result + '</div>');

					}
				});
				return false;	
}
function addUser()
{			  
				var name = $('#name').val();
				var username = $('#username').val();
				var password = $('#password').val();
				var email = $('#email').val();
				var ajaxattempt = $('#hiddenUser').val();
			  
			 var bool=$('#formadduser').validate().form();
			 if(!bool){
			
			 	$('p#msg').replaceWith('<h3 id="msg">** valori form non validi **</h3>');
			 	
			}
			else{
				 $('#formuser').append('<img src="img/loading.gif" alt="Currently Loading" id="loading" />');
				$.ajax({
				
					url: 'include/backOfficeHandler.inc.php',
					type: 'POST',
					data: 'name=' + name + '&username=' + username + '&password=' + password + '&email=' + email + '&ajaxattempt=' + ajaxattempt,
				
					success: function(result) {
					  $('#loading').fadeOut(500, function() {
							$(this).remove();
						});
						$('div#formadduser').replaceWith('<div id="response">' + result + '</div>');

					}
				});
			}
				return false;	
}
function delUser(idn)
{
        var id = idn.substring(1);
		var ajaxattempt = $('#hiddendelUser').val();
				
	
       // if(confirm("Are you sure?"))
        //{			
        	
    				$.ajax({
    				
    					url: 'include/backOfficeHandler.inc.php',
    					type: 'POST',
    					data: 'id=' + id + '&ajaxattempt=' + ajaxattempt,
    					
    					success: function(result) {
						   $("#i"+id).parents('table').effect("explode");
					     }
    					
    				});
      //  }	
        	
        	
        	
					
				return false;
}


function addGift()
{
	
			
			  
			  //var image= $('#imageGift').val();
				var nameita = $('#nameGiftIta').val();
				var nameeng = $('#nameGiftEng').val();
				var link = encodeURI($('#linkGift').val());
				var linkname = encodeURI($('#linkGiftName').val());
				var price = encodeURI($('#price').val());
				
				var fckcontentita = escape(FCKeditorAPI.GetInstance('editGiftIta').GetXHTML());
				//var fckcontenteng = escape(FCKeditorAPI.GetInstance('editGiftEng').GetXHTML());
				var fckcontenteng=0;
				var ajaxattempt = $('#hiddenGift').val();
			  
			  var bool=$('#formaddgift').validate().form();
				 if(!bool){
				
					
					
				}else{
			     $('#formgift').append('<img src="img/loading.gif" alt="Currently Loading" id="loading" />');
					$.ajax({
					
						url: 'include/backOfficeHandler.inc.php',
						type: 'POST',
						fileElementId:'#imageGift',
						data: 'nameita=' + nameita + '&nameeng=' + nameeng + '&link=' + link + '&linkname=' + linkname +'&price=' + price + '&fckcontentita=' + fckcontentita + '&fckcontenteng=' + fckcontenteng + '&ajaxattempt=' + ajaxattempt,
						dataType: 'json',
						success: function(result) {
						  $('#loading').fadeOut(500, function() {
								$(this).remove();
							});
							$('div#formaddgift').replaceWith('<div id="response">' + result + '</div>');

						}
					});
			}
				return false;	
}
function delGift(idn)
{
          var id = idn.substring(1);
				var ajaxattempt = $('#hiddendelGift').val();
				
	
        if(confirm("Are you sure?"))
        {			
        	
    				$.ajax({
    				
    					url: 'include/backOfficeHandler.inc.php',
    					type: 'POST',
    					data: 'id=' + id + '&ajaxattempt=' + ajaxattempt,
    					
    					success: function(result) {
						   $("#i"+id).parents('table').effect("explode");
					     }
    					
    				});
        }	
        	
        	
        	
					
				return false;
}

function addService()
{
	
			   
			  
				var nameita = $('#nameServiceIta').val();
				var nameeng = $('#nameServiceEng').val();
				var script = $('#nameScript').val();
				var groups=new Array();
                                var position = $('#position').val();	
				var ajaxattempt = $('#hiddenService').val();
                               
			 alert(nameita+" "+nameeng);
		
				$("input[@type='checkbox'][@name='grouplist[]']").each( 
				function() 
				{ 
					if (this.checked) 
					{ 
						
						groups.push(this.value);
					} 
				}); 
				
				 var bool=$('#formaddservice').validate().form();
			
			 if(!bool){
			
			 
			 	
			}else{	
				
			 	$('#formservice').append('<img src="img/loading.gif" alt="Currently Loading" id="loading" />');  
				$.ajax({
				
					url: 'include/backOfficeHandler.inc.php',
					type: 'POST',
					data: 'nameita=' + nameita +'&group=' + groups + '&nameeng=' + nameeng + '&script=' + script+ '&position='+position+ '&ajaxattempt=' + ajaxattempt,
				
					success: function(result) {
					  $('#loading').fadeOut(500, function() {
							$(this).remove();
						});
							
						//$('div#formaddservice').replaceWith('<div id="response">' + result + '</div>');
                                        
					}
				});
			}
				return false;	
}

function editService()
{	   
			  
				var nameEn = $('#nameServiceEng').val();
				var nameIt = $('#nameServiceIta').val();
				var script = $('#nameScript').val();
				var id=$('#id').val();
				var position = $('#position').val();	
				var languageIt = $('#lanIt').val();
				var languageEn = $('#lanEn').val();
				var ajaxattempt = $('#hiddenModService').val();
				
					
				$.ajax({
								
					url: 'include/backOfficeHandler.inc.php',
					type: 'POST',
					data: 'nameIt=' + nameIt +'&nameEn=' + nameEn + '&script=' + script + '&position=' + position + '&languageIt='+languageIt+'&languageEn='+languageEn+ '&id=' + id + '&ajaxattempt=' + ajaxattempt,
											
					success: function(result) {
											
						$('#formmodservice').replaceWith('<div id="response">' + result + '</div>');

					}
				});
				
				return false;	
}

function delService(idn)
{
        var id = idn.substring(1);
        var ajaxattempt = $('#hiddendelService').val();
				
	
       // if(confirm("Are you sure?"))
        //{			
        	
    				$.ajax({
    				
    					url: 'include/backOfficeHandler.inc.php',
    					type: 'POST',
    					data: 'id=' + id + '&ajaxattempt=' + ajaxattempt,
    					
    					success: function(result) {
						   $("#i"+id).parents('table').effect("explode");
					     }
    					
    				});
      //  }	
        	
        	
        	
					
				return false;
}
function validateForm(){
	
	
	$(".control").validate();

}

